<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

</body>
</html>
<script>
    const calculate = (num1, num2, operation) => {
        if (operation == "add") {
            return num1 + num2;
        } else if (operation == "subtract") {
            return num1 - num2;
        } else if (operation == "multiply") {
            return num1 * num2;
        } else if (operation == "divide") {
            return num1 / num1;
        } else {
            return "无效操作";
        }
    }
    console.log(calculate(5, 3, "add"));
    console.log(calculate(10, 4, 'subtract'));
    console.log(calculate(2, 7, 'multiply'));
    console.log(calculate(15, 3, 'divide'));
    console.log(calculate(8, 2, 'unknown'));
</script>